#include<iostream>
#include<string>
#include<vector>
using namespace std;

class Solution {
public:
    string convert(string s, int numRows)
    {
        if (numRows < 2)
            return s;
        vector<string> r(numRows);
        int flag = -1;
        int i = 0;
        for (auto x : s)
        {
            r[i] += x;
            if (i == numRows - 1 || i == 0)
                flag = -flag;
            i += flag;
        }
        string res;
        for (auto e : r)
            res += e;
        return res;
    }
};